<template>
	<view class="content">
			<view class="mokuai" style="margin: 30rpx;padding: 20rpx 30rpx;"  v-for="(item,index) in list" :key="index">
				<view class="info_title" style="font-size: 34rpx;padding-bottom: 5px;margin-bottom: 4px;">
					{{item.addtime}}
					<text class="right">
						{{item.paymoney}}
					</text>
				</view>
				<view class="clear shenhe-text" >
					<text class="left">还款金额 </text>
					<text class="right">{{item.paymoney}}</text>
				</view>
				<view class="clear shenhe-text" >
					<text class="left">利息 </text>
					<text class="right">{{item.investment}}</text>
				</view>
				<view class="clear shenhe-text" >
					<text class="left">平台 </text>
					<text class="right">{{item.paytype}}</text>
				</view>
				
			</view>
		    <image src="../../static/img/nodata.png" class="no-data" v-if="ishas1"  mode="widthFix"></image>
		
	</view>
</template>

<script>
	    import httpPath from '@/static/js/path.js';
		import {getlogin} from '@/static/js/login.js';
		import {fmoney} from '@/static/js/login.js';
		import {timestampToDate} from '@/static/js/login.js';
		import MescrollUni from "@/components/mescroll-uni/uni-load-more.vue";
		var  _self,
		page = 1;
		export default {
			
			components: {
			    MescrollUni
			},
			data() {
				return {
					// color:"#e0e7f4"
					color:"#ff5a5a",
					list:[],
					user:"",//登录信息
					id:"",
					loadingType: 0,
					contentText: {
						contentdown: "上拉显示更多",
						contentrefresh: "正在加载...",
						contentnomore: "没有更多数据了"
					},
					ishas1:false,
				}
			},
			onLoad(option) {
			    this.user = getlogin();
			    if(!this.user.islogin){
			    	uni.showModal({
			    	   showCancel:false,
			    	   content:"您还没有登录，请登录"
			    	})
			    	uni.navigateTo({
			    		url:"../public/login"
			    	})
			    }	
				this.id=option.id;
				if(this.user.type==2){
					this.user.member_id=option.member_id;
				}
				page = 1;
				_self = this;
				// _self.type = e.id;
				_self.fnGetData();
			   
			   
			},
			onReachBottom: function() {
				if (_self.loadingType != 0) {//loadingType!=0;直接返回
					return false;
				}
				_self.loadingType = 1;
				uni.showNavigationBarLoading();//显示加载动画
				page++;//每触底一次 page +1
				uni.request({
					url: httpPath.filePath+"/api.php/index/member/pay_loan_list",
					method:'POST',
					header:{'content-type':'application/x-www-form-urlencoded'},
					data: {page:page,member_id:this.user.member_id,id:this.id},
					success: (res) => {
						if (res.data.result.length==0) {//没有数据
							_self.loadingType = 2;
							uni.hideNavigationBarLoading();//关闭加载动画
							return false;
						}
						for (let i = 0;i < res.data.result.length;i++) {
							res.data.result[i].addtime=timestampToDate(res.data.result[i].addtime)
							res.data.result[i].paymoney=fmoney(res.data.result[i].paymoney)
							res.data.result[i].investment=fmoney(res.data.result[i].investment)
							res.data.result[i].capital=fmoney(res.data.result[i].capital)
							_self.list.push(res.data.result[i]);
							// this.list[i].capital=fmoney(this.list[i].capital)
							// this.list[i].use_capital=fmoney(this.list[i].use_capital)
					 	    //this.list[i].used_capital=fmoney(this.list[i].used_capital)
						}
						_self.loadingType = 0;//将loadingType归0重置
						uni.hideNavigationBarLoading();//关闭加载动画
					}
				});
			
			},
			onPullDownRefresh() {
				page=1
				_self.loadingType=0;
			    this.fnGetData();   
			    setTimeout(function () {
			            uni.stopPullDownRefresh();
			        }, 1000);
			},
			methods: {
				
				goaddkehu(id){
					uni.navigateTo({
						url:"editkehu"
					})
				},
				fnGetData(){
						uni.request({
							url: httpPath.filePath+"/api.php/index/member/pay_loan_list",
							method: 'POST',
							data:  {page:page,member_id:this.user.member_id,id:this.id},
							header:{'content-type':'application/x-www-form-urlencoded'},
							success: res => {
								if(res.data.code == "200"){
									this.list=res.data.result;
									if(this.list.length==0){
										this.ishas1=true;
									}else{
										this.ishas1=false;
									}
									for(let i=0;i<this.list.length;i++){
										this.list[i].addtime=timestampToDate(this.list[i].addtime)
										this.list[i].paymoney=fmoney(this.list[i].paymoney)
										this.list[i].investment=fmoney(this.list[i].investment)
										this.list[i].capital=fmoney(this.list[i].capital)
									}
									console.log(this.list)
								}
							}
						});
					},	
				}
				
			}			

	</script>
</script>

<style>
	@import "../../colorui/main.css";
</style>
